function executSql(){
	fDisPatchFlag = null;
	fStatus = null;
	fClosed = null;
	var field1 = $("#field1").val();
	var operator1 = $("#operator1").val();
	var value1 = $("#value1").val();
	if(field1 != "blank" && (field1 == "" || field1 == undefined || operator1 == "" || operator1 == undefined || value1 == "" || value1 == undefined)){
		swal_Tips("第一搜索组信息不完整，不能进行搜索");
		return false;
	}
	if(field1 == "fWorkCenter")
		field1 = "fDepId";
	if(field1 == "fStockName")
		field1 = "fStockId";
	if(field1 == "fOrderBillNo")
		fOrderBillNo =value1;
	if(field1 == "fDisPatchFlag"){
		if(value1 == 1)
			fDisPatchFlag = 1;
	}
	if(field1 == "fStatus"){
		if(value1 == 1)
			fStatus = 1;
		else if(value1 == 5)
			fStatus = 5;
		else
			fStatus = 3;
	}
	if(field1 == "fClosed"){
		if(value1 == 0)
			fClosed = 0;
		else
			fClosed = null;
	
	}
	value1 = value1.trim();
	if(field1 != "blank" && field1 != "fRwId" && field1 != "fDisPatchFlag" && field1 != "fStatus"  && field1 != "fClosed"
		 && field1 != "fBillNo" && field1 != "fNumber"&& field1 != "fName"&& field1 != "fOperSN"
		 && field1 != "fNote" && field1 != "fBillerName"
	){
		sqlCombine = "("+field1+" "+switchOper(operator1,value1)+" )";
	}
	else if(field1 == "fBillNo"){
		sqlCombine = "("+"so"+"."+field1+" "+switchOper(operator1,value1)+" )";
	}
	else if(field1 == "fName"||field1 == "fNumber"){
		sqlCombine = "("+"ie"+"."+field1+" "+switchOper(operator1,value1)+" )";
	}
	else if(field1 == "fOperSN"){
		sqlCombine = "("+"soe"+"."+field1+" "+switchOper(operator1,value1)+" )";
	}
	else if(field1 == "fNote"){
		sqlCombine = "("+"c"+"."+field1+" "+switchOper(operator1,value1)+" )";
	}
	else if(field1 == "fBillerName"){
		sqlCombine = "("+"u"+"."+"name "+switchOper(operator1,value1)+" )";
	}
	if(field1 == "fRwId"){
		if(value1 == 1){
			sqlCombine = "(fNumber like '05.%' or fNumber like '5.%' or fNumber like '99.%')";
		}
		else{
			sqlCombine = "(fNumber not like '05.%' and fNumber not like '5.%' and fNumber not like '99.%')";
		}
	}
	for(var i = 2 ;i <= searchCount;i++){
		var index = i-1;
		var andOr = $("#andOr"+index).val();
		var field = $("#field"+i).val();
		var operator = $("#operator"+i).val();
		var value = $("#value"+i).val();
		if(field == "blank")
			continue;
		if(field != "blank" && (field == "" || field == undefined || operator == "" || operator == undefined || value == "" || value == undefined)){
			swal_Tips("第"+i+"搜索组信息不完整，不能进行搜索");
			return false;
		}
		if(field == "fWorkCenter")
			field = "fDepId";
		if(field == "fStockName")
			field = "fStockId";
		if(field == "fDisPatchFlag"){
			if(value == 1)
				fDisPatchFlag = 1;
			continue;
		}
		if(field == "fStatus"){
			if(value == 1)
				fStatus = 1;
			else if(value == 5)
				fStatus = 5;
			else
				fStatus = 3;
			continue;
		}
		if(field == "fClosed"){
			if(value == 0)
				fClosed = 0;
			continue;
		}
	   if(field == "fOrderBillNo"){
		   fOrderBillNo =value;
			continue;
		}
		value = value.trim();
		if(sqlCombine == "" && field != "fRwId" && field != "fBillNo" && field != "fNumber"&& field != "fName"&& field != "fOperSN"
			 && field != "fNote" && field != "fBillerName"
		){
			sqlCombine += " ("+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine == "" && field == "fBillNo"){
			sqlCombine += " ("+"so"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine != "" && field == "fBillNo"){
			sqlCombine += " "+andOr +" ("+"so"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine == "" && field == "fNumber"){
			sqlCombine += " ("+"ie"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine != "" && field == "fNumber"){
			sqlCombine += " "+andOr +" ("+"ie"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine == "" && field == "fName"){
			sqlCombine += " ("+"ie"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine != "" && field == "fName"){
			sqlCombine += " "+andOr +" ("+"ie"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine == "" && field == "fOperSN"){
			sqlCombine += " ("+"soe"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine != "" && field == "fOperSN"){
			sqlCombine += " "+andOr +" ("+"soe"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine == "" && field == "fNote"){
			sqlCombine += " ("+"c"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine != "" && field == "fNote"){
			sqlCombine += " "+andOr +" ("+"c"+"."+field+" "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine == "" && field == "fBillerName"){
			sqlCombine += " ("+"u"+"."+"name "+switchOper(operator,value)+" )";
		}
		else if (sqlCombine != "" && field == "fBillerName"){
			sqlCombine += " "+andOr +" ("+"u"+"."+"name "+switchOper(operator,value)+" )";
		}
		
		else if (sqlCombine != "" && field != "fRwId"){
			sqlCombine += " "+andOr +" ("+field+" "+switchOper(operator,value)+" )";
		}
		else if(sqlCombine == "" && field == "fRwId"){
			if(value == 1){
				sqlCombine += "(fNumber like '05.%' or fNumber like '5.%' or fNumber like '99.%')"
			}
			else{
				sqlCombine += "(fNumber not like '05.%' and fNumber not like '5.%' and fNumber not like '99.%')"
			}
		}
		else{
			if(value == 1){
				sqlCombine +=  " "+andOr +"(fNumber like '05.%' or fNumber like '5.%' or fNumber like '99.%')"
			}
			else{
				sqlCombine +=  " "+andOr +"(fNumber not like '05.%' and fNumber not like '5.%' and fNumber not like '99.%')"
			}
		}
		
		/*if(operator == "<>" && field != "fRwId" && field != "blank"){
			sqlCombine += " or ("+field+" is NULL )" ;
		}*/
	}
	console.log(sqlCombine);
	for(var l = 1 ;l <= searchCount;l++){
		if(sqlCombine.indexOf("fName")!=-1){
			$("#value"+l).unbind().bind("keyup",function (event) {
				if(event.keyCode == "118"){
					IDName = event.target.id;
					jj=IDName.substring(5);
					console.log(jj);
					$("#queryName").text("查询-物料代码");
					$("#ERPModal").modal('show');
				}
				if (event.keyCode == 13) { 
					$('#query').triggerHandler('click'); 
				}
			});
			
		}else if(sqlCombine.indexOf("fNumber")!=-1){
			$("#value"+l).unbind().bind("keyup",function (event) {
				if(event.keyCode == "118"){
					IDName = event.target.id;
					jj=IDName.substring(5);
					$("#queryName").text("查询-物料代码");
					$("#ERPModal").modal('show');
				}
				if (event.keyCode == 13) { 
					$('#query').triggerHandler('click'); 
				}
			});
		}else if(sqlCombine.indexOf("fModel")!=-1){
			$("#value"+l).unbind().bind("keyup",function (event) {
				if(event.keyCode == "118"){
					IDName = event.target.id;
					jj=IDName.substring(5);
					$("#queryName").text("查询-物料代码");
					$("#ERPModal").modal('show');
				}
				if (event.keyCode == 13) { 
					$('#query').triggerHandler('click'); 
				}
			});
		}
		else{
			$("#value"+l).unbind().bind("keyup",function (event) {
				if(event.keyCode == "118"){
					IDName = event.target.id;
					jj=IDName.substring(5);
					$("#queryName").text("查询-物料代码");
					$("#ERPModal").modal('show');
				}
				if (event.keyCode == 13) { 
					$('#query').triggerHandler('click'); 
				}
			});
		}
	}
}
function switchOper(operator,value){
	var statement;
	switch(operator){
	case 'like':
		statement = "like "+"'%"+value+"%'";
		break;
	case 'left like':
		statement = "like "+"'"+value+"%'";
		break;
	case 'right like':
		statement = "like "+"'%"+value+"'";
		break;
	default:
		statement = operator+" '"+value+"'";
	}
	return statement;
}